<template>
	<view class="product_container">
		<view class="product_box">
			<view class="product_all" v-for="item in productListNew" :key="item.id"
				:class="[isActive == item.id ? 'product_all_active' : '']" @click="handleChooseTab(item)">
				<view class="product_img_box">
					<image :src="item.img" mode="" class="product_img"></image>
				</view>
				<view class="product_name">
					{{ item.name }}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: ['productList'],
		data() {
			return {
				productListNew: [],
				isActive: 0
			}
		},
		watch: {
			productList: {
				handler(newVal) {
					this.productListNew = newVal
				},
				immediate: true
			}
		},
		methods: {
			// 切换tab
			handleChooseTab(val) {
				this.$emit('handleChooseTab', val)
				this.isActive = val.id
				 if (val.name == '宽带产品') {
					// uni.showToast({
					// 	title: '正在开发中',
					// 	icon: 'none'
					// })
					// return
				} else if (val.name == '权益') {
					uni.showToast({
						title: '正在开发中',
						icon: 'none'
					})
					return
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.product_container {
		// background: #fff;
		// border-radius: 20rpx;
		// border: 1px solid #FCFCFC;
		padding: 10rpx 30rpx;
		margin: 10rpx 0;

		.product_box {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.product_all {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.product_img_box {
					width: 80rpx;
					height: 80rpx;

					.product_img {
						width: 100%;
						height: 100%;
					}
				}

				.product_name {
					font-family: screen-font;
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
				}
			}

			.product_all_active {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.product_img_box {
					width: 80rpx;
					height: 80rpx;

					.product_img {
						width: 100%;
						height: 100%;
					}
				}

				.product_name {
					font-family: screen-font;
					font-weight: 500;
					font-size: 24rpx;
					color: #1E366A;
				}
			}
		}
	}
</style>